import { _decorator, Color, color, Component, director, instantiate, Label, Node, Sprite, tween } from 'cc';

const { ccclass, property } = _decorator;

@ccclass('HandbookView')
export class HandbookView extends Component {



    ndContent: Node = null;


    protected onLoad(): void {
        this.ndContent = this.node.getChildByName("Board").getChildByName("Content").getChildByName("view").getChildByName("content");
    }

    protected onEnable(): void {
        this.clearAllContent();
        this.showContent("Background" as EHandBookMenuType);

    }

    protected onDisable(): void {
        
    }

    start() {
    }

    update(deltaTime: number) {
     
    }

    onButtonShowContent(event: any,type: EHandBookMenuType) {
        console.log("showContent:", type);
        this.clearAllContent();
        this.showContent(type);
        // switch (type) {
        //     case EHandBookMenuType.BackGround:
        //         this.showContent(EHandBookMenuType.BackGround);
        //     case EHandBookMenuType.Hero:
        //         this.showContent(EHandBookMenuType.Hero);
        //         break;
        //     case EHandBookMenuType.Equipment:
        //         this.showContent(EHandBookMenuType.Equipment);
        //         break;
        //     default:
        //         break;

        // }
        
    }



    clearAllContent() {
        console.log("clearAllContent");
        // 获取ndContent所有子节点并隐藏
        for (let i = 0; i < this.ndContent.children.length; i++) {
            console.log("clearAllContent:", this.ndContent.children[i]);
            this.ndContent.children[i].active = false;
        }

    }

    showContent(type: EHandBookMenuType) {
        console.log("showContent:", type);

        this.ndContent.getChildByName(type as string).active = true;
        
    }



}

export enum EHandBookMenuType {
    BackGround = "BackGround",
    Hero = "Hero",
    Equipment = "Equipment",
}


